package com.ywk.pattern._28_vistor;

import java.util.ArrayList;
import java.util.List;

public class ObjectStructure {
    private List<Person> elements = new ArrayList<>();

    //增加
    public void attach(Person element) {
        elements.add(element);
    }

    public void remove(Person element) {
        elements.remove(element);
    }

    public void display(Action visitor) {
        for (Person element : elements) {
            element.accept(visitor);
        }
    }
}
